package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ParamHolidaysDTO;
import com.hzeport.bgs22emduty.entity.ParamHolidays;
import com.hzeport.bgs22emduty.entity.ParamSmsTemplate;
import com.hzeport.bgs22emduty.service.ParamSmsTemplateService;
import com.hzeport.bgs22emduty.vo.ParamHolidays.ParamHolidaysSaveVO;
import com.hzeport.bgs22emduty.vo.ParamSmsTemplate.ParamSmsSaveVO;
import com.hzeport.bgs22emduty.vo.ParamSmsTemplate.ParamSmsTemplateListVO;
import com.hzeport.bgs22emduty.vo.ParamSmsTemplate.ParamSmsTemplateSaveVO;
import com.hzeport.bgs22emduty.vo.base.PageVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 参数表-短信模板表：
此表中存储，各种类型的短信模板信息
 *
 * @author code generator
 * @date 2022-12-02 11:21:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/paramsmstemplate")
@Api(value = "paramsmstemplate", tags = "短信表")
@Slf4j
public class ParamSmsTemplateController {
    @Resource
    private  ParamSmsTemplateService paramSmsTemplateService;
    @Resource
    private LoginCompoentService loginCompoentService;

    @ApiOperation(value = "列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public BaseResult<Page<ParamSmsTemplateListVO>> list(@RequestBody PageVO pageVO){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramSmsTemplateService.list(pageVO,userInfo);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    @OperLog( systemName = "DXGL", description = "DXSC")
    public BaseResult delete(@RequestParam("id") String id){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramSmsTemplateService.delete(id,userInfo);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
     public BaseResult<ParamSmsTemplateSaveVO> detail(@RequestParam("id") String id){
       return paramSmsTemplateService.detail(id);
    }

    @ApiOperation(value = "保存")
    @PostMapping("/save")
    @OperLog( systemName = "DXGL", description = "DXBC")
    public BaseResult save(@RequestBody ParamSmsTemplateSaveVO paramSmsTemplateSaveVO) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramSmsTemplateService.saveData(paramSmsTemplateSaveVO,userInfo);
    }

    @ApiOperation(value = "总署保存")
    @PostMapping("/saveZs")
    @OperLog( systemName = "DXGLZS", description = "DXBCZS")
    public BaseResult saveZs(@RequestBody ParamSmsSaveVO dto) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramSmsTemplateService.saveZs(dto,userInfo);
    }

    @ApiOperation(value = "短信开关")
    @RequestMapping(value = "smsSwitch",method = RequestMethod.POST)
    @OperLog( systemName = "DXKG", description = "DXKG")
    public BaseResult<String> smsSwitch(@RequestBody ParamSmsTemplateSaveVO dto){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramSmsTemplateService.smsSwitch(dto,userInfo);
    }

}
